package com.hdaccp.xingmu.dao;

import com.hdaccp.xingmu.entity.House;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import sun.awt.SunHints;

import java.util.List;

public interface house extends JpaRepository<House,Long> {

    @Query(value="select h.id,h.doornumber,t.`name`,s.`name`,d.`name`,h.floor,x.`name`,i.`name`,h.measure,h.remark,(select u.`name` from userdetails as u where u.doornumber = h.`doornumber`) as `user` from house as h\n" +
            "INNER JOIN typeb as t on h.type = t.id\n" +
            "INNER JOIN sale as s on h.sale = s.id\n" +
            "INNER JOIN danyuan as d on h.danyuan = d.id\n" +
            "INNER JOIN huxing as X on h.huxing = x.id\n" +
            "INNER JOIN direction as i on h.direction = i.id",nativeQuery = true)
    public List<House> list();

    List<House> findAll(Specification specification);

    Page<House> findAll(Specification specification, Pageable pageable);


}
